Skip to content

Fix the no-AES-CBC, no-store and NSS store build configurations - #295

Merged
LinuxJedi merged 3 commits into
wolfSSL:masterfrom
Frauschi:build-config-fixes
Nov 10, 2026
Merged

LinuxJedi merged 3 commits into
wolfSSL:masterfrom
Frauschi:build-config-fixes

Conversation

@Frauschi

Copy link
Copy Markdown
Member

Fix four build configurations that fail to compile on master, and add CI jobs so they stay fixed.

Changes

  • Move the TLS PRF code (MechToMac, TLS 1.2 master key derive) out of the AES-CBC section so --disable-aescbc builds against a wolfSSL with the PRF.
  • Build ML-KEM, LMS and XMSS support with WOLFPKCS11_NO_STORE: guard the store-only object fields and keep the LMS/XMSS import, verify and attribute code outside the store-only block.
  • Build WP11_Slot_TokenKeyIsZero (debug test hook) only with a store, since it reads the token key.
  • Add WP11_NSS_STORE_DIR for NSS with the file store and use it for storeDir, storeDirLock, WP11_SetStoreDir and the configdir parsing in C_Initialize. This fixes NSS builds without a store, with WOLFPKCS11_CUSTOM_STORE and with WOLFPKCS11_TPM_STORE.

Testing

  • New unit-test.yml jobs: no_aescbc, no_keystore_pqc, no_keystore_debug, no_keystore_nss; the --disable-aescbc TODO is removed.
  • test_private_object_access: NSS lets public sessions find private objects, and with a store logout hides them only by encoding them. Without a store the test now checks that NSS finds the object after logout.

The WOLFSSL_HAVE_PRF block in internal.c, holding MechToMac and the
TLS 1.2 master key derive functions, sat inside the AES-CBC section.
A --disable-aescbc build against a wolfSSL with the TLS PRF failed to
compile, because the TLS MAC code calls MechToMac whatever the AES
configuration. The block uses no AES, so move it ahead of the AES
section.

Replace the CI TODO for --disable-aescbc with a job. The
no_derive_secret_key job also disables AES-CBC, but builds against a
wolfSSL without the PRF, so it never reached this code.
A build with -DWOLFPKCS11_NO_STORE and --enable-mlkem, --enable-lms or
--enable-xmss did not compile. WP11_Object_Free and the LMS and XMSS
public-key setters use object->encoded and object->keyData, which only
exist with a store. The LMS and XMSS import, verify and attribute code
also sat in the store-only part of internal.c, so its callers saw
undeclared functions.

Keep only the LMS and XMSS encode, decode, load and store functions in
the store-only part and guard the store fields. Without a store a key
is never encoded, so it is always freed.

Add a CI job that builds all post-quantum algorithms without a store.
With WOLFPKCS11_NO_STORE, a debug build failed because the
WP11_Slot_TokenKeyIsZero test hook reads the token key, which only
exists with a store. Its tests already skip builds without a store, so
declare and build the hook only with one.

NSS builds used the file store's storeDir under conditions that did not
exclude the other stores. Without a store or with
WOLFPKCS11_CUSTOM_STORE, storeDirLock was defined but unused. With
WOLFPKCS11_TPM_STORE, WP11_Library_Final freed storeDir, which does not
exist there. With either of them, C_Initialize called WP11_SetStoreDir,
which only the file store defines. Define WP11_NSS_STORE_DIR for NSS
with the file store and guard storeDir, its lock, the free,
WP11_SetStoreDir and its caller with it.

test_private_object_access expects a private token object to be hidden
from a public session after logout. NSS mode lets public sessions find
private objects, and with a store the object is skipped only because
logout encodes it. Without a store it stays decoded, so for NSS without
a store the test checks that the object is found instead.

Add CI jobs for debug and NSS builds without a store.
Copilot AI balanced review requested due to automatic review settings November 10, 2026 09:57
@Frauschi Frauschi self-assigned this Nov 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the build-configuration fixes and added CI coverage.

No open issues 🎉

What changed in this PR

This PR fixes wolfPKCS11 build configurations with AES-CBC disabled, storage disabled, or NSS using non-file storage, and adds CI coverage to prevent regressions.

Changes:

  • Separates TLS PRF code from AES-CBC guards and makes post-quantum key handling compatible with no-store builds.
  • Restricts NSS store-directory handling and the token-key debug hook to applicable storage configurations.
  • Adds four CI jobs and adjusts the private-object access test for NSS without storage.
File Description
wolfpkcs11/​internal.h Defines the NSS file-store guard and guards storage-dependent declarations.
tests/​pkcs11test.c Adjusts private-object lookup expectations for NSS no-store builds.
src/​wolfpkcs11.c Limits NSS config-directory parsing to file-store builds.
src/​internal.c Corrects conditional compilation for TLS PRF, post-quantum keys, and storage helpers.
.github/​workflows/​unit-test.yml Adds no-AES-CBC and three no-store CI configurations.

Review effort: Balanced

@Frauschi

Copy link
Copy Markdown
Member Author

@claude review

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #295

Scan targets checked: wolfpkcs11-src, wolfpkcs11-bugs
Not reviewed (no scan target covers them): .github/workflows/unit-test.yml
Coverage: 4 of 4 in-scope changed file(s) opened by the reviewer

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Max

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed this PR and found no bugs. It changes key-free paths and an access-control test expectation in a PKCS#11 crypto library, so a human look is still worthwhile.

What was reviewed:

  • The moved and added WOLFPKCS11_NO_STORE guards in src/internal.c, checked for #if/#endif balance around the ML-KEM, LMS/HSS, XMSS and symmetric stored-record helpers.
  • The PQC free paths in WP11_Object_Free and SetHssKey/SetXmssKey: under NO_STORE, encoded never exists, so the wc_*_Free call runs every time. This is consistent and causes no double free.
  • WP11_NSS_STORE_DIR now gates storeDir, storeDirLock, WP11_SetStoreDir and configdir parsing the same way in all of them. The AES-CBC helpers moved below the PRF block without being changed.
  • No build or test was run, so the four new CI configurations were not compiled here.
Extended reasoning...

The change rearranges preprocessor guards in src/internal.c, src/wolfpkcs11.c and wolfpkcs11/internal.h, adds four CI build jobs, and changes one test. The guards affect key ownership and free logic for ML-KEM, LMS and XMSS objects. The test now treats it as expected that NSS+NO_STORE builds let a public session find a private object, which is an access-control behavior a maintainer should confirm is intended. On NSS builds with CUSTOM_STORE or TPM_STORE, C_Initialize now ignores configdir without any error. The change is in a crypto library and alters security-relevant test expectations, so deferring was chosen over approving.

@Frauschi Frauschi assigned wolfSSL-Bot and unassigned Frauschi Nov 10, 2026
@Frauschi
Frauschi requested a review from LinuxJedi November 10, 2026 10:21
@LinuxJedi
LinuxJedi merged commit a96067e into wolfSSL:master Nov 10, 2026
108 checks passed
@Frauschi
Frauschi deleted the build-config-fixes branch November 10, 2026 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants